local miewu = fk.CreateSkill{
    name = "heg__miewu",
}

Fk:loadTranslationTable{
  ["heg__miewu"] = "灭吴",
  [":heg__miewu"] = "每回合限一次，你可以弃置1个“武库”标记，将一张牌当做任意一张基本牌或锦囊牌使用或打出；若如此做，你摸一张牌。",

  ["$heg__miewu1"] = "倾荡之势已成，石城尽在眼下。",
  ["$heg__miewu2"] = "吾军势如破竹，江东六郡唾手可得。",
}

miewu:addEffect("viewas",{
    pattern = ".",
    prompt = "#miewu",
    handly_pile = true,
    interaction = function(self, player)
      local all_names = Fk:getAllCardNames("btd")
      local names = player:getViewAsCardNames(miewu.name, all_names)
      if #names == 0 then return end
      return UI.CardNameBox {choices = names, all_choices = all_names}
    end,
    card_filter = function(self, player, to_select, selected)
      return #selected == 0 and table.contains(player:getHandlyIds(true), to_select)
    end,
    view_as = function(self, player, cards)
      if #cards ~= 1 or not self.interaction.data then return end
      local card = Fk:cloneCard(self.interaction.data)
      card:addSubcards(cards)
      card.skillName = miewu.name
      return card
    end,
    before_use = function(self, player, use)
      player.room:removePlayerMark(player, "@heg_wuku")
    end,
    enabled_at_play = function(self, player)
      return player:getMark("@heg_wuku") > 0 and player:usedSkillTimes(miewu.name) == 0
    end,
    enabled_at_response = function(self, player, response)
      return player:getMark("@heg_wuku") > 0 and player:usedSkillTimes(miewu.name) == 0
    end,
})

local miewu_spec = {
  mute = true,
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and table.contains(data.card.skillNames, miewu.name) and not player.dead
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, miewu.name)
  end,
}

miewu:addEffect(fk.CardUseFinished, miewu_spec)
miewu:addEffect(fk.CardRespondFinished, miewu_spec)

return miewu